//
//  CYNMainViewController.m
//  App
//
//  Created by blank on 2019/1/23.
//  Copyright © 2019年 NowStudio Co.,Ltd. All rights reserved.
//

#import "CYNMainViewController.h"
#import "CYNFlutterViewController.h"
#import "CYNReactNativeViewController.h"
#import "CYNTabBarViewController.h"
#import <QMUIKit/QMUIKit.h>
#import "App-Swift.h"

@interface CYNMainViewController ()

@property(nonatomic, copy) NSArray<NSString *> *dataSource;

@end

@implementation CYNMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //    self.tableView
    self.dataSource = @[
                        @"Native-ObjC",
                        @"Native-Swift",
                        @"Flutter",
                        @"React Native"
                        ];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    QMUITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"QMUITableViewCell"];
    if (!cell) {
        cell = [[QMUITableViewCell alloc] initForTableView:tableView withStyle:UITableViewCellStyleDefault reuseIdentifier:@"QMUITableViewCell"];
    }
    cell.textLabel.text = self.dataSource[(NSUInteger) indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    switch (indexPath.row) {
            case 0: {
                CYNTabBarViewController *tabBarViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CYNTabBarViewController"];
                [self presentViewController:tabBarViewController animated:YES completion:nil];
            }
            break;
            
            case 1: {
                CYNSwiftExampleViewController *swiftViewController = CYNSwiftExampleViewController.create;
                [self presentViewController:swiftViewController animated:YES completion:nil];
                
            }
            break;
            
            case 2: {
                CYNFlutterViewController *flutterViewController = [[CYNFlutterViewController alloc] initWithNibName:nil bundle:nil];
                [self.navigationController pushViewController:flutterViewController animated:YES];
            }
            break;
            
            case 3: {
                CYNReactNativeViewController *reactNativeViewController = [[CYNReactNativeViewController alloc] initWithNibName:nil bundle:nil];
                [self.navigationController pushViewController:reactNativeViewController animated:YES];
            }
            break;
            
        default:
            break;
    }
}


@end
